package com.service;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.entity.Admins;
import com.entity.Cart;
import com.entity.Page;
import com.entity.Pets;
import com.entity.User;


@Service
@Transactional
public class PetsServiceImpl implements PetsService  {
	@Resource
	private com.dao.order.pets.PetsDao petsDaoImpl;
	
	@Override
	public List<Pets> findAll(){
		return petsDaoImpl.findAll();
		
	}
	@Override
	public Pets findPetsById(int id) {
		Pets pets=petsDaoImpl.selectPets(id);
		return pets;
	}
	@Override
	public void updatePets(Pets p) {
		petsDaoImpl.updatePets(p);
		
	}
	@Override
	public List<Pets> findPetsByPage(int pageName, int pageSize) {
		return petsDaoImpl.findPetsByPage(pageName, pageSize);
	}
	@Override
	public Page<Pets> PetsPage(int pageNum){
		try {
			Page<Pets> page=new Page<>(pageNum,5);
			page.setTotalCount(petsDaoImpl.findCount());
			page.setList(petsDaoImpl.findPetsByPage(pageNum, 5));
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	@Override
	public Pets select(int id){
		return petsDaoImpl.selectPets(id);
	}

	@Override
	public int subPrice(int id, int account) {
		return petsDaoImpl.subPrice(id, account);
	}
	@Override
	public User user(int id) {
		User user = petsDaoImpl.user(id);
		return user;
	}
	@Override
	public Admins admin(int id) {
		Admins admin = petsDaoImpl.admin(id);
		System.out.println(admin+"service层");
		return admin;
	}
	@Override
	public void updateAdmin(Admins admin) {
		petsDaoImpl.updateAdmin(admin);
		
	}
}
	
	

